from util.AutoMation import AutoMation
from DrissionPage import ChromiumPage
import pandas as pd

# 创建页面对象，并启动或接管浏览器
page = ChromiumPage()
amt = AutoMation(page)

def main():
    __name__ = "__main__"
    url  ='http://www.jiangshunsmart.com/index.php/admins/Login/index.html'
    username = 'jizhicms'
    password = 'jizhicms'
    seo_xfile = r"E:\project\documents\webseo.xlsx"
    
    article_release(url,username,password,seo_xfile)

def article_release(url,username,password,seo_xfile):
    if(not page.ele('批量复制',timeout=0.2)):
        amt.start(url,username,password)
        amt.article_manage()
    # 读取本地excel文件
    data = pd.read_excel(seo_xfile)
    for i in range(len(data)):
        seo_data={'title':data['title7'][i],'keywords':data['keywords'][i],'litpic':data['litpic'][i]}
        amt.article_copy(seo_data)
        if(i%15==0):
            # 刷新页面
            page.refresh()  
            amt.article_manage()

if __name__ == "__main__":
    main()